package com.yanqu.road.server.manger;

import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.entity.monopolymarket.MonopolyMarket;
import com.yanqu.road.entity.servergroup.ICrossServerGroup;
import com.yanqu.road.server.TempMgr;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class SystemCrossServerGroupMgr extends TempMgr{

    private static Map<Integer, ICrossServerGroupAccess> accessMap = new ConcurrentHashMap<>();

    @Override
    public boolean reload() throws Exception {
        return true;
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean init() throws Exception {
        accessMap.put(eSystemId.BeautyEscort.getValue(), EscortServerGroupMgr.initServerGroupAccess());
        accessMap.put(eSystemId.CrossHuaBen.getValue(), UnionHuaBenServerGroupMgr.initServerGroupAccess());
        accessMap.put(eSystemId.Union.getValue(), CrossUnionServerGroupMgr.initServerGroupAccess());
        return reload();
    }

    @Override
    public boolean stop() {
        return false;
    }

    public static int getGroupIdByServerId(int systemId, long serverId) {
        return accessMap.get(systemId).getGroupIdByServerId(serverId);
    }

    public static ICrossServerGroup getServerGroup(int systemId, int groupId) {
        return accessMap.get(systemId).getServerGroup(groupId);
    }

    public static ICrossServerGroup getServerGroupByServerId(int systemId, long serverId) {
        return accessMap.get(systemId).getServerGroupByServerId(serverId);
    }

    public static Set<Long> getGroupServer(int systemId, int groupId){
        return accessMap.get(systemId).getGroupServer(groupId);
    }

    public static void reloadServerGroup(int systemId){
        accessMap.get(systemId).reloadServerGroup();
    }

    public static Map<Integer, ICrossServerGroupAccess> getAccessMap() {
        return accessMap;
    }
}
